<?php
class PublicatioPriceMergeCustomizationForm extends BasePublicationPriceForm{
	const FORM_CUSTOMIZATIONS="custom";
	function configure(){
		$percentageTypes=PublicationPriceTable::getPercentageTypes();
		$this->widgetSchema["percentage_type"]= new sfWidgetFormChoice(array("choices"=>$percentageTypes));
		$this->validatorSchema["percentage_type"]= new sfValidatorChoice(array("choices"=>array_keys($percentageTypes)));
		unset($this["created_at"],$this["updated_at"],$this["publication_id"]);
		$customization= new sfForm();
		foreach($this->getObject()->getCustomizations() as $key=>$customPrice){
			$customization->embedForm("custom_".$customPrice->getId(), new PublicationPriceCustomForm($customPrice));
		}
		$this->setWidget("num_prices", new sfWidgetFormInputHidden());
		$this->getWidgetSchema()->setLabels(
			array("num_prices"=>"Número de Cuotas",
				  "percentage_type"=>"Tipo",
				  "percentage"=>"Monto",
				  "description"=>"Descripción",
				  "price_type_id"=>"Tipo de Precio"
		));
		$this->embedForm(self::FORM_CUSTOMIZATIONS, $customization);
	}
}